package 其他;
/*
 *@Author: helen
 *@Date:   2021/5/9 18:56
 *@Description:
    找出字符串中长度为n的所有子串数量
 */

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int n = str.charAt(str.length() - 1) - 48;
        char[] chars = str.substring(0, str.length() - 2).toCharArray();

        //判断字符串是否为空或长度大于52 , 寻找的子串长度是否大于原字符串
        if(chars.length == 0 || chars.length > 52 || n > chars.length){
            System.out.println(0);
            return;
        }
        //判断是否含重复
        for (int i = 0; i < str.length() - 2; i++) {
            if(str.indexOf(str.charAt(i), i+1) != -1){
                System.out.println(0);
                return;
            }
        }

        int l = chars.length;
        for (int i = 1; i < n; i++) {
            l = l * (l - i);
        }
        for (int i = 1; i <= n; i++) {
            n  = n * (n - 1);
        }
        System.out.println(l/n);

    }
}

/*
有长为n的二进制字符串0101010,规则：在区间[x,y]内，0变成1,1变成0，区间共有q个；
 */
/*public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        sc.nextLine();
        String str = sc.nextLine();
        char[] arr = str.toCharArray();
        int[][] qujian = new int [q][2];
        for(int i = 0; i < q; i++) {
            qujian[i][0] = sc.nextInt();
            qujian[i][1] = sc.nextInt();
        }
        for(int i = 0; i < q; i++){
            for(int j = qujian[i][0]; j < qujian[i][1]; j++){
                if(arr[j] == '0'){
                    arr[j] = '1';
                }else{
                    arr[j] = '0';
                }
            }
        }
        for(int i = 0; i < arr.length; i++){
            System.out.print(arr[i]);
        }
    }
}

 */
